package com.zte.cl.repository;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.zte.cl.model.OrigWebpage;

@Repository
public interface OrigWebpageRepository extends JpaRepository<OrigWebpage, String> {
	List<String> findByContentIsNull();
	
	@Transactional
	@Modifying
	@Query("delete from OrigWebpage o where o.content is null")
	void deleteByContentIsNull();
	
	@Query("select o.pageId from OrigWebpage o where o.content is null")
	List<String> findPageIdByContentIsNull();
	
	@Query("select o.pageId from OrigWebpage o where o.channelId = ?1")
	List<String> findPageIdByChannelId(String channelId);
	
	@Transactional
	@Modifying
	@Query("delete from OrigWebpage o where o.pageId in (?1)")
	void deleteByPageIdIn(List<String> pageIdList);
	
	@Query("select o.pageId from OrigWebpage o where o.insertTime < ?1")
	List<String> findPageIdByInsertTimeBefore(Date date);
}
